<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
  mixins: [Vue.prototype.$vFN.Mixins.Base, Vue.prototype.$vFN.Mixins.Edit],
  components: {},
  data() {
    return {
      appWindow: window,
      appList: [],

      // 页面接口地址
      apiUrl: {
        create: "mall-site-portal/platform/create",
        update: "mall-site-portal/platform/update",
        detail: "mall-site-portal/platform/getAppList",
      },
    };
  },
  methods: {
    async getList() {
      let _data = await this.$vFN.Http.post(
        {
          url: "mall-site-portal/platform/getAppList",
          data: {
            id: this.id,
          },
        },
        this.appWindow
      );
      if (_data._ok) {
        console.error(_data.data);
        this.appList = _data.data;
      }
      this.mixinEdit_loading = false;
    },
    async submit() {
      let _authAppIdLst = [];
      this.appList.forEach((item) => {
        if (item.isSelected == 1) {
          _authAppIdLst.push(item.id);
        }
      });
      let _data = await this.$vFN.Http.post(
        {
          url: "mall-site-portal/platform/authApp",
          data: {
            authAppIdLst: _authAppIdLst,
            id: this.id,
          },
        },
        this.appWindow
      );
      if (_data._ok) {
        console.error(_data.data);
        this.mixinEdit_editVisible = false;
        this.$vFN.Tools.messageSuccess("设置成功");
      }
    },

    // 反选
    selectInvert(){
      
      this.appList.forEach( item => {
          if(item.isSelected == 0){
              item.isSelected = 1;
          }else{
             item.isSelected = 0;
          }
      })

    },

    // 重置
    resetting(){

      this.appList.forEach( item => {
          item.isSelected = 0;
      })

    },

    // 取消
    async cancel() {
      this.mixinEdit_editVisible = false;
    },

    // 初始化
    async init() {
      this.mixinEdit_loading = true;
      this.getList();
      this.mixinEdit_editVisible = true;
    },
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>